#!/bin/bash

#  no longer installed, remove from systemd
if [[ "$1" = "0" ]]; then
    rm -f /etc/default/lifi

    if [[ -d /run/systemd/system ]]; then
        systemctl disable lifi
        rm -f /etc/systemd/system/lifi.service
        systemctl daemon-reload
    fi

    if [[  -f /var/log/cphm/lifi.log ]]; then
        rm -f /var/log/cphm/lifi.log
    fi

fi

# upgrade, restart service
if [[ $1 -ge 1 ]]; then
    if [[ -d /run/systemd/system ]]; then
        systemctl try-restart lifi.service >/dev/null 2>&1 || :
    fi
fi
